/*
* JSA mixin plugin
*
* Mixin is a mechanism for code reuse
*
* To implement mixins, the 'mixin' property is used and expected array of mixing objects.
*
* @example
*
* App.MixinA = {
*     propertyA: "propertyA"
* };
* App.MixinB = {
*     propertyB: "propertyB"
* };
* App.Silo = function() {
*     return {
*         __mixin__: [ App.MixinA, App.MixinB ],
*         ownPropery: "Own property"
*     }
* };
* var module = App.Silo.createInstance();
* module.ownPropery is defined
* module.propertyA is defined
* module.propertyB is defined
*
* @package JSA.Mixin
* @author sheiko
* @version 2.03
* @license MIT
* @copyright (c) Dmitry Sheiko http://www.dsheiko.com
* @jscs standard:Jquery
* Code style: http://docs.jquery.com/JQuery_Core_Style_Guidelines
*/
/*jshint sub:true*/
/*global module: false */
(function( global, undefined ) {
    "use strict";
    global.jsa = global.jsa || {};
   /**
    * Extends object factory with traits support
    */
    global.jsa.Hook = global.jsa.Hook || [];
    /**
     * Hook handler
     * @param {object} instace
     * @param {array} args
     */
    global.jsa.Hook.push(function( instance, args ) {
        if ( instance[ "__mixin__" ] && global.jsa.isArray( instance[ "__mixin__" ] ) ) {
            for (var i = 0, len = instance[ "__mixin__" ].length; i < len; i++ ) {
                var trait = instance[ "__mixin__" ][ i ];
                for (var member in trait) {
                    if ( trait.hasOwnProperty( member ) ) {
                        instance[ member ] = trait[ member ];
                    }
                }
            }
        }
    });

}( this ));